<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
      layout:decorate="~{layout/base}">
<head>
    <title>故障列表 - 维修故障排查系统</title>
</head>
<body>
    <div layout:fragment="content">
        <div class="row">
            <div class="col-12">
                <div class="d-flex justify-content-between align-items-center mb-4">
                    <h1>故障列表</h1>
                    <a th:href="@{/faults/new}" class="btn btn-primary">
                        <i class="fas fa-plus me-1"></i>新建故障
                    </a>
                </div>
                
                <div class="card">
                    <div class="card-header">
                        <div class="row">
                            <div class="col-md-6">
                                <h5 class="mb-0">故障记录</h5>
                            </div>
                            <div class="col-md-6">
                                <div class="input-group">
                                    <input type="text" class="form-control" placeholder="搜索设备名称...">
                                    <button class="btn btn-outline-secondary" type="button">
                                        <i class="fas fa-search"></i>
                                    </button>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="card-body">
                        <div class="table-responsive">
                            <table class="table table-hover">
                                <thead class="table-light">
                                    <tr>
                                        <th>故障编号</th>
                                        <th>设备名称</th>
                                        <th>故障描述</th>
                                        <th>优先级</th>
                                        <th>状态</th>
                                        <th>创建时间</th>
                                        <th>操作</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    <tr th:each="fault : ${faults}">
                                        <td>
                                            <strong th:text="${fault.faultNumber}"></strong>
                                        </td>
                                        <td th:text="${fault.deviceName}"></td>
                                        <td th:text="${#strings.abbreviate(fault.faultDescription, 50)}"></td>
                                        <td>
                                            <span class="badge" 
                                                  th:classappend="${fault.priority == 'URGENT'} ? 'bg-danger' : 
                                                                 ${fault.priority == 'HIGH'} ? 'bg-warning' : 
                                                                 ${fault.priority == 'MEDIUM'} ? 'bg-info' : 'bg-secondary'"
                                                  th:text="${fault.priority}"></span>
                                        </td>
                                        <td>
                                            <span class="badge" 
                                                  th:classappend="${fault.status.name() == 'PENDING'} ? 'bg-warning' : 
                                                                 ${fault.status.name() == 'IN_PROGRESS'} ? 'bg-primary' : 
                                                                 ${fault.status.name() == 'RESOLVED'} ? 'bg-success' : 'bg-secondary'"
                                                  th:text="${fault.status}"></span>
                                        </td>
                                        <td th:text="${#temporals.format(fault.createdAt, 'yyyy-MM-dd HH:mm')}"></td>
                                        <td>
                                            <a th:href="@{/faults/{id}(id=${fault.id})}" class="btn btn-sm btn-info">
                                                <i class="fas fa-eye"></i>
                                            </a>
                                            <a href="#" class="btn btn-sm btn-warning">
                                                <i class="fas fa-edit"></i>
                                            </a>
                                        </td>
                                    </tr>
                                </tbody>
                            </table>
                        </div>
                        
                        <div class="d-flex justify-content-between align-items-center mt-3">
                            <div>
                                <small class="text-muted">显示 1-10 条，共 <span th:text="${#lists.size(faults)}">0</span> 条记录</small>
                            </div>
                            <nav>
                                <ul class="pagination pagination-sm mb-0">
                                    <li class="page-item disabled">
                                        <a class="page-link" href="#" tabindex="-1">上一页</a>
                                    </li>
                                    <li class="page-item active"><a class="page-link" href="#">1</a></li>
                                    <li class="page-item"><a class="page-link" href="#">2</a></li>
                                    <li class="page-item"><a class="page-link" href="#">3</a></li>
                                    <li class="page-item">
                                        <a class="page-link" href="#">下一页</a>
                                    </li>
                                </ul>
                            </nav>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</body>
</html>
